package com.yc.weixin.web.Handler;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yc.utils.YcUtils;
import com.yc.weixin.entity.ArticleType;
import com.yc.weixin.entity.WeiXinTempPage;
import com.yc.weixin.service.ArticleTypeService;

@Controller
@RequestMapping("/typeButton")
public class ArticleTypeHandler {
		
	@Resource(name="articleTypeService")
	private ArticleTypeService articleTypeService;
	@RequestMapping("/findArticleTypeByPage.do")
	@ResponseBody
	public WeiXinTempPage<ArticleType> findArticleTypeByPage(int page,int rows){
		WeiXinTempPage<ArticleType>	result=articleTypeService.findArticleTypeByPage((page-1)*rows,rows);
		if(result==null){
			result=new WeiXinTempPage<ArticleType>();
			result.setTotal(0);
			result.setRows(new ArrayList<ArticleType>());
		}
		return result;
	}
	
	@RequestMapping("/findArticleType.do")
	@ResponseBody
	public List<ArticleType> findArticleType(){
		List<ArticleType> articleTypes=articleTypeService.findArticleType();		
		YcUtils.logger.debug("获取微信文章类型"+articleTypes);
		return articleTypes;
	}
}
